package com.scpii.universal.pns.dao.impl;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.scpii.universal.hibernate.dao.impl.BaseDaoImpl;
import com.scpii.universal.pns.dao.UserPointRanksDao;
import com.scpii.universal.pns.entity.UserPointRanks;

@Repository
public class UserPointRanksDaoImpl extends BaseDaoImpl<UserPointRanks, Long>
		implements UserPointRanksDao {

	@Override
	public UserPointRanks getByAppIdAndMaxPoints(Long appid, Long maxPoints) {
		String hql = "FROM UserPointRanks upr WHERE upr.appid=:appid AND upr.maxPoints=:maxPoints";
		Query query = getSession().createQuery(hql);
		query.setParameter("appid", appid);
		query.setParameter("maxPoints", maxPoints);
		return (UserPointRanks) query.uniqueResult();
	}

}
